package com.lg.partition51;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/4/15 15:20
 */
public class P5002专心OI找祖先 {

    private static final int N = 10010, M = 2 * N, MOD = (int) (1e9 + 7);
    private static int[] h = new int[N], e = new int[M], ne = new int[M], depth = new int[N], size = new int[N];
    private static int[] ans = new int[N];
    private static int n, m, r, idx = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        r = Integer.parseInt(ss[1]);
        m = Integer.parseInt(ss[2]);
        Arrays.fill(h, -1);
        for (int i = 0; i < n - 1; i++) {
            ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]);
            add(a, b);
            add(b, a);
        }
        dfs(r, -1, 0);
        for (int i = 1; i <= n; i++) ans[i] = cal(i);
        if (m > 0) ss = reader.readLine().split(" ");
        for (int i = 0; i < m; i++) writer.write(ans[Integer.parseInt(ss[i])] + "\n");
        writer.flush();
    }

    private static int cal(int p) {
        int res = size[p];
        for (int i = h[p]; i != -1; i = ne[i]) {
            int v = e[i];
            //保证到的都是自己的子树节点
            if (depth[v] < depth[p]) continue;
            res = (res + ((size[p] - size[v]) * size[v]) % MOD) % MOD;
        }
        return res;
    }

    private static void dfs(int u, int fa, int d) {
        size[u] = 1;
        depth[u] = d;
        for (int i = h[u]; i != -1; i = ne[i]) {
            int v = e[i];
            if (v == fa) continue;
            dfs(v, u, d + 1);
            size[u] += size[v];
        }
    }

    private static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }
}
